#pragma once
#include "蛇和食物初始化.h"
#include "地图UI初始化.h"

int speed;

struct MID
{
	int X;
	int Y;
}mid1,mid2;
void move(char key)//初始化蛇的移动状态
{
	int i;
	mid1.X = snake.body[0].X;
	mid1.Y = snake.body[0].Y;
	for (i = 1; i < snake.size; i++)
	{
		mid2.X = snake.body[i].X;
		mid2.Y = snake.body[i].Y;
		snake.body[i].X = mid1.X;
		snake.body[i].Y = mid1.Y;
		mid1.X = mid2.X;
		mid1.Y = mid2.Y;
	}
	if (key == 'd' || key == 'D')
		snake.body[0].X++;
	else if (key == 'w' || key == 'W')
		snake.body[0].Y--;
	else if (key == 'a' || key == 'A')
		snake.body[0].X--;
	else if (key == 's' || key == 'S')
		snake.body[0].Y++;
	set(mid1.X, mid2.Y);
	printf(" ");
}